function loadImg() {
  webpMachine = new webpHero.WebpMachine()
  webpMachine.webpSupport.then(r => {
    var n = !1
      , s = "my";
    s += "2ecret",
      s += "782ec",
      s += "ret";
    var c = 300;
    $("img.lazy_img").each(function (e) {
      ($(this).attr("src").indexOf("blob:") > -1 || $(this).attr("src").indexOf("base64") > -1)
        ? window.URL.revokeObjectURL($(this).attr("src"))
        : p($(this)[0].getAttribute("data-r-src"), $(this)[0])
    });
    async function p(e, r, n = 0) {
      let a = new XMLHttpRequest;
      a.open("GET", e, !0),
        a.addEventListener("progress", function (e) {
          let n = e.loaded / (e.loaded + 6e3) * 100;
        }),
        a.responseType = "arraybuffer",
        a.onerror = async function () { console.log('请求图片发出错误') },
        a.onload = async function () {
          4 == a.readyState && (200 == a.status
            ? r.src = await g(a.response, s, r)
            : 0 == n && (n += 1, await p(e, r, n)))
        },
        a.send()
    }
    function f(e) {
      const t = e.sigBytes
        , r = e.words
        , n = new Uint8Array(t);
      for (var s = 0, a = 0; s != t;) {
        var i = r[a++];
        if (n[s++] = (4278190080 & i) >>> 24,
          s == t)
          break;
        if (n[s++] = (16711680 & i) >>> 16,
          s == t)
          break;
        if (n[s++] = (65280 & i) >>> 8,
          s == t)
          break;
        n[s++] = 255 & i
      }
      return n
    }
    const h = e => new Promise(t => setTimeout(t, e))
      , v = e => {
        let t = new FileReader;
        return t.readAsDataURL(e),
          new Promise(e => {
            t.onloadend = (() => {
              e(t.result)
            })
          })
      };
    async function g(e, t, s) {
      let a = e, i = CryptoJS.enc.Utf8.parse(t), o = CryptoJS.lib.WordArray.create(a), c, l = f(CryptoJS.AES.decrypt({
        ciphertext: o
      }, i, {
        iv: i,
        padding: CryptoJS.pad.Pkcs7
      })), d = "";
      if (r) {
        let e = new Blob([l]);
        d = URL.createObjectURL(e)
      } else {
        let e = 0;
        for (; "" === d && e < 100;) {
          if (e++,
            !n) {
            let e;
            n = !0,
              d = await webpMachine.decode(l),
              n = !1
          }
          "" === d && await h(300)
        }
      }
      return d
    }
  }
  )
};

/**
 * 将url解析成json队形
 * @url 如果有不是从location对象中获取的url，可以使用url参数传入url的字符串。
 * 返回一个json对象：
 *  url_：基础的请求地址，没有参数。
 *  其他参数，以键值对形式。
 **/
function urlToJson(url = decodeURIComponent(location.href)) {
  let uu = new URL(url);
  uu.search_ = {};
  if (uu.search) {
    var searchArr = uu.search.substring(1).split("&");
    let s = {};
    for (let index = 0; index < searchArr.length; index++) {
      var s_ = searchArr[index].split("=");
      s[s_[0]] = s_[1]
    }
    uu.search_ = s;
  }
  return uu;
}

/**
 * 将一个对象的值拼接成url
 * @obj 要拼接成查询字符串，注意，对象里面的属性值不能是对象类型，如果是对象类型，则会转换成JSON字符串再拼接
 * @pathname 传入的url，可以不传。
 **/
function jsonToUrl(obj = {}, url = decodeURIComponent(location.href)) {
  if (Object.keys(obj).length === 0) return url;
  let oUrl = urlToJson(url);
  let AllSearch = { ...oUrl.search_, ...obj };
  let skeys = Object.keys(AllSearch);
  if (skeys.length > 0) {
    let sString = [];
    skeys.forEach(item => { sString.push(item + '=' + AllSearch[item]); })
    return oUrl.origin + oUrl.pathname + '?' + sString.join('&') + oUrl.hash;
  } else {
    return oUrl.origin + oUrl.pathname + oUrl.hash;
  }
}

/**
* 将指定日期时间或当前日期时间转换成指定的格式。
* @fmt {String} 日期格式
* @timestamp {Date} 标准时间。选填。
*/
function format(fmt, timestamp) {
  const date = timestamp ? new Date(timestamp) : new Date()
  const o = {
    "Y+": date.getFullYear(),
    "M+": date.getMonth() + 1,     // 月
    "D+": date.getDate(),          // 日
    "h+": date.getHours(),         // 时
    "m+": date.getMinutes(),       // 分
    "s+": date.getSeconds(),       // 秒
    "W": date.getDay()             // 周
  }
  for (var k in o) {
    if (new RegExp("(" + k + ")").test(fmt)) {
      fmt = fmt.replace(RegExp.$1, () => {
        if (k === 'W') {                                    // 星期几
          const week = ['日', '一', '二', '三', '四', '五', '六']
          return week[o[k]]
        } else if (k === 'Y+' || RegExp.$1.length == 1) {    // 年份 or 小于10不加0
          return o[k]
        } else {
          return ("00" + o[k]).substr(("" + o[k]).length)  // 小于10补位0
        }
      })
    }
  }
  return fmt
}